<?php
//This class creates a html-File by parsing a template.
//Using frames or iframes require to create HTML-files
//because frames are needing links to html-files. They cannot
//be shown by using the smarty-command display.

class CreateHtml {
		
 	var $smarty;	
 	
 	public function __construct($smarty) {
		$this->smarty = $smarty;
	}
	
	//converts a template to a html-file
	//templates are loaded from assigned template-library 
	//the result is saved to the assigned compiler-library
	//further, a link is set from the server-root-path to the 
	//compile_directory: LINK_TO_CONTENT
	
	public function template_to_html ($template, $outputname) {
		$inputdir = $this->smarty->template_dir."/".$template;
		$html_code = $this->smarty->fetch($inputdir);
		$outdir = $this->smarty->compile_dir."/".$outputname;
		$outlink = $this->smarty->compile_link."/".$outputname;
		$this->smarty->assign('LINK_TO_CONTENT', $outlink);
		/*var_dump($inputdir); echo '<br>';
		var_dump($outdir); echo '<br>';
		var_dump($html_code); echo '<br>';
		var_dump($outlink); echo '<br>';
		die();*/		
		$handle = fopen($outdir, "w");
		fwrite($handle, $html_code);
		fclose($handle);		
	}
}
?>
